package com.lxit.dao;

import com.lxit.pojo.Question;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface QuestionMapper {
    @Delete({
        "delete from tb_question",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into tb_question (id, type_id, ",
        "subject, answerA, ",
        "answerB, answerC, ",
        "answerD, answerE, ",
        "answerF, answer, ",
        "analysis, knowpoint_id, ",
        "chapter_id, repertory_id)",
        "values (#{id,jdbcType=INTEGER}, #{typeId,jdbcType=INTEGER}, ",
        "#{subject,jdbcType=VARCHAR}, #{answera,jdbcType=VARCHAR}, ",
        "#{answerb,jdbcType=VARCHAR}, #{answerc,jdbcType=VARCHAR}, ",
        "#{answerd,jdbcType=VARCHAR}, #{answere,jdbcType=VARCHAR}, ",
        "#{answerf,jdbcType=VARCHAR}, #{answer,jdbcType=VARCHAR}, ",
        "#{analysis,jdbcType=VARCHAR}, #{knowpointId,jdbcType=INTEGER}, ",
        "#{chapterId,jdbcType=INTEGER}, #{repertoryId,jdbcType=INTEGER})"
    })
    int insert(Question record);

    int insertSelective(Question record);

    @Select({
        "select",
        "id, type_id, subject, answerA, answerB, answerC, answerD, answerE, answerF, ",
        "answer, analysis, knowpoint_id, chapter_id, repertory_id",
        "from tb_question",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    Question selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Question record);

    @Update({
        "update tb_question",
        "set type_id = #{typeId,jdbcType=INTEGER},",
          "subject = #{subject,jdbcType=VARCHAR},",
          "answerA = #{answera,jdbcType=VARCHAR},",
          "answerB = #{answerb,jdbcType=VARCHAR},",
          "answerC = #{answerc,jdbcType=VARCHAR},",
          "answerD = #{answerd,jdbcType=VARCHAR},",
          "answerE = #{answere,jdbcType=VARCHAR},",
          "answerF = #{answerf,jdbcType=VARCHAR},",
          "answer = #{answer,jdbcType=VARCHAR},",
          "analysis = #{analysis,jdbcType=VARCHAR},",
          "knowpoint_id = #{knowpointId,jdbcType=INTEGER},",
          "chapter_id = #{chapterId,jdbcType=INTEGER},",
          "repertory_id = #{repertoryId,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Question record);
}